<?php
/**
 * 轮播
 */
namespace Common\Model;
class MarqueeModel extends BaseModel{
	//轮播位置
	const MARQUEE_ALL 				= 0;
	const MARQUEE_WAP_INDEX 		= 1;//wap主页
	const MARQUEE_WAP_POINT_MALL 	= 2;//wap积分商城首页
	const MARQUEE_WEB_INDEX 		= 3;//web主页
	const MARQUEE_HOUSE_INDEX 		= 4;//web主页

	public function __construct() {
	}

	public static function getSize($posSwitch){
		switch($posSwitch){
			case self::MARQUEE_WAP_INDEX:
				return array(640,350);
				break;
			case self::MARQUEE_WAP_POINT_MALL:
				return array(640,250);
				break;
			case self::MARQUEE_WEB_INDEX;
				return array(1180,350);
				break;
		}
	}


	/**
	 * 获取轮播列表
	 * Author: shijy
	 * @param int $position 位置
	 * @param int $count 数量
	 * @return mixed
	 */
	public static function getMarqueeList($position=MarqueeModel::MARQUEE_WAP_INDEX,$count=5,$from=0){
		$marqueeM=M('marquee',null,DB_MAIN_CFG);
		if($from){
			$where = "position={$position} and isOn=1";
		}else{
			$where = "position={$position}";
		}
		$marqueeList=$marqueeM->where($where)->order("showOrder desc,id desc")->limit($count)->select();
		return $marqueeList;
	}

}